<!DOCTYPE html>
<html>
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <meta name="viewport" content="initial-scale=1.0, user-scalable=no" />
    <style type="text/css">
        body, html,#allmap {width: 100%;height: 100%;overflow: hidden;margin:0;font-family:"微软雅黑";}
    </style>
    <script type="text/javascript" src="http://api.map.baidu.com/api?v=2.0&ak=FhU5h94BlhuQP4FSvECsxCSgWCBovTwt"></script>
    <title>地址解析</title>
</head>
<body>
<div id="allmap"></div>
<input type="hidden" th:value="${address}" id="address"/>
<input type="hidden" th:value="${lng}" id="lng"/>
<input type="hidden" th:value="${lat}" id="lat"/>
</body>
</html>
<script type="text/javascript">
    // 百度地图API功能
    var map = new BMap.Map("allmap");
    var address =document.getElementById("address").value;
    var lng =document.getElementById("lng").value;
    var lat =document.getElementById("lat").value;


    var point = new BMap.Point(lng,lat);
    map.centerAndZoom(point,12);
    // 创建地址解析器实例
    var myGeo = new BMap.Geocoder();
    // 将地址解析结果显示在地图上,并调整地图视野
    myGeo.getPoint(address, function(point){
        if (point) {
            map.centerAndZoom(point, 16);
            map.addOverlay(new BMap.Marker(point));
        }else{
            alert("您选择地址没有解析到结果!");
        }
    }, "");
</script>
